<include file="Base/header" /> 	
<link href="__PUBLIC__/chosen/chosen.css" rel="stylesheet" />
<script src="__PUBLIC__/chosen/chosen.jquery.js"></script> 

<div class="page-container">
	<include file="Base/menu" /> 
	<div class="page-content">
		<div class="container-fluid">
			<div class="row-fluid">
					<div class="span12"> 
						<!-- BEGIN PAGE TITLE & BREADCRUMB-->
						<h3 class="page-title">
						</h3>
						<ul class="breadcrumb">
							<li>
								<i class="icon-home"></i>
								<a href="/index.php/Admin/">首页</a> 
								<i class="icon-angle-right"></i>
							</li>
							<li><a href="/index.php/Admin/Other">工具</a></li>
						</ul>
						<!-- END PAGE TITLE & BREADCRUMB-->
					</div>
			</div>
			<div class="row-fluid">
					<div class="span12">
						<!-- BEGIN EXAMPLE TABLE PORTLET-->
						<div class="portlet box blue">
							<div class="portlet-title">
								<div class="caption"><i class="icon-globe"></i>二维码列表</div>
								<div class="tools">
									<a href="javascript:;" class="collapse"></a>
									<a href="javascript:;" class="reload"></a>
									<a href="javascript:;" class="remove"></a>
								</div>
							</div>
							<div class="portlet-body">
                                <div class="clearfix">
                                    <div class="btn-group">
                                        <a href="__CONTROLLER__/DeviceAdd"><button id="sample_editable_1_new" class="btn green">
                                        新增&nbsp;&nbsp;<i class="icon-plus"></i>
                                        </button></a>
                                    </div>
                                </div>
                                <div id="sample_1_wrapper" class="dataTables_wrapper form-inline" role="grid">
                                <div class="row-fluid">
                                    <form method="get" action="__URL__/Index" >
                                    <div class="span3">
                                        <div id="sample_1_length" class="dataTables_length">
                                            <select size="1" id="mySelect" name="page_size" aria-controls="sample_1" class="m-wrap small" onchange="submit(this.value)">
                                                <option id="page10" value="10">10</option>
                                                <option id="page20" value="20">20</option>
                                                <option id="page50" value="50">50</option>
                                                <option id="page100" value="100">100</option>
                                            </select> 条/每页</label>
                                        </div>
                                    </div>
                                    <div class="span5">
                                        <div class="dataTables_filter" id="sample_1_filter" >
                                        客户：
                                        <select size="3" name="shop_id" id="sum_shop_id" class="m-wrap small shopId">
                                            <option>=请选择=</option>
                                            <foreach name="shop" item="v">
                                                <option value="{$v['id']}" <if condition="$v['id'] eq $shop_id">selected=selected</if>>{$v['shop_name']}</option>
                                            </foreach>
                                        </select>
                                        <button onclick="shousuos()" class="green">搜索</button>
                                        <script>
                                            $(".shopId").chosen({
                                                search_contains: true,
                                                no_results_text: "没有找到",
                                            });
                                        </script>
                                        </div>
                                    </div>
                                    </form>

                                </div>
<table class="table table-striped table-bordered table-hover dataTable"
id="sample_1" aria-describedby="sample_1_info">
    <thead>
        <tr role="row">
            <!-- <th style="width: 24px;" class="sorting_disabled" role="columnheader"
            rowspan="1" colspan="1" aria-label="">
                <div class="checker">
                    <span>
                        <input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes">
                    </span>
                </div>
            </th> -->
            <th style="width: 10px;">
                <input type="checkbox" id="selAll" onclick="selectAll();" />全选
            </th>
            <th class="sorting" role="columnheader" tabindex="0" aria-controls="sample_1"
            rowspan="1" colspan="1" aria-label="" style="width: 50px;">
                ID
            </th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1"
            colspan="1" aria-label="Email" style="width: 50px;">
                分类名字
            </th>
            <th class="hidden-480 sorting" role="columnheader" tabindex="0" aria-controls="sample_1"
            rowspan="1" colspan="1" aria-label="" style="width: 40px;">
                名称
            </th>
            <th class="hidden-480 sorting" role="columnheader" tabindex="0" aria-controls="sample_1"
            rowspan="1" colspan="1" aria-label="" style="width: 40px;">
                添加时间
            </th>
            <th class="hidden-480 sorting" role="columnheader" tabindex="0" aria-controls="sample_1"
            rowspan="1" colspan="1" aria-label="" style="width: 40px;">
                二维码
            </th>
            <th class="hidden-480 sorting_disabled" role="columnheader" rowspan="1"
            colspan="1" aria-label="Joined" style="width: 50px;">
                管理
             </th>

        </tr>
    </thead>

    <foreach name="data" item="vo"> 

    <tbody id="allcheck" role="alert" aria-live="polite" aria-relevant="all">
     <tr class="gradeX odd">
            <!-- <td class=" sorting_1">
                <div class="checker">
                    <span>
                        <input type="checkbox" class="checkboxes" value="1">
                    </span>
                </div>
            </td> -->
            <td>
                <input type="checkbox" name="checkAll" onclick="setSelectAll();" value="{$vo.id}" />
            </td>
            <td class=" ">
                {$vo.id}
            </td>
            <td class="hidden-480 ">
               {$vo.cate_name}
            </td>
            <td class="hidden-480 ">
                {$vo.name}
            </td>
            <td class="hidden-480 ">
                {$vo.add_time|date="Y-m-d H:i:s", ###}
            </td>
            <td class="hidden-480 ">
                <div name="layer-photos-demo" class="layer-photos-demo" style="height: 24px;width: 24px">
                    <img layer-pid="{$vo.id}" layer-src="{$vo.code_num}" src="{$vo.code_num}" alt="二维码">
                </div>
                <!-- <a id="kan" onclick="kan()" style="cursor: pointer;">查看</a> --> 
            </td>
            <td class="center hidden-480 ">
                <!-- <a href="{:U('Admin/Device/DeviceUp',array('id'=>$vo['id']))}" style="cursor: pointer;">
                   编辑
                </a> -->

                <a id="del" onclick="del({$vo.id})" style="cursor: pointer;">
                   删除
                </a>

                <a href="{:U('Admin/Device/download',array('id'=>$vo['id']))}" target="_blank" style="cursor: pointer;">
                   下载
                </a>
            </td>
        </tr>
    </tbody>


    </foreach>
</table>
<!-- 分页 -->
<a class="delete" onclick="sbts()">
    <span class="label label-warning" style='cursor:pointer;'>全选删除</span></a>
    &nbsp;&nbsp;|&nbsp;&nbsp;
<a class="delete" onclick="sbt({$shop_id})">
    <span class="label label-warning" style='cursor:pointer;'>下载</span></a> 二维码包

<div class="row-fluid">
    <div class="span6">
        <div class="dataTables_info" id="sample_1_info">
          共{$count}条数据记录。
        </div>
    </div>
    <div class="span6">
        <div class="dataTables_paginate paging_bootstrap pagination">
            {$page}
        </div>
    </div>
</div>								
								</div>
							</div>
						</div>
						<!-- END EXAMPLE TABLE PORTLET-->
					</div>
				</div>
		</div>
	</div>
</div>
<include file="Base/footer" /> 
<script type="text/javascript" src="__PUBLIC__/js/common.js" ></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script type="text/javascript">
function del(id){
    $.ajax({
        type:'POST',
        dataType: "json",
        url: "{:U('Admin/Device/DeviceDel')}",
        data: {"id":id},
        success:  function(result){
            if(result.status==1){
                layer.alert(result.info,function(){self.location="__MODULE__/Device/Index";});
            }else if(result.status==0){
                //失败
                layer.alert(result.info);
            }
        }
    });
}
function sbt(id){
    self.location="__MODULE__/Device/downloads?id="+id;
}
</script>
<script type="text/javascript">

    layer.photos({
        photos: '.layer-photos-demo'
        ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
    });
    
</script>
<script language="javascript" type="text/javascript">
function submit(){
    $.ajax({
        type:"get",
        url:"index?page_size",
        async:false,
    })
}
element=document.getElementById('page'+{$Think.session.page_size});
element.setAttribute("selected","selected");
</script>
<script language="javascript">
var obj = document.getElementById("sum_shop_id_chosen");
obj.style.setProperty('width','200px');
//选中全选按钮，下面的checkbox全部选中
var selAll = document.getElementById("selAll");
function selectAll()
{
  var obj = document.getElementsByName("checkAll");

  if(document.getElementById("selAll").checked == false)
  {

  for(var i=0; i<obj.length; i++)
  {

    obj[i].checked=false;
  }
  }else
  {

  for(var i=0; i<obj.length; i++)
  {
    obj[i].checked=true;
  }
  }
}

function sbts(){

    var key=0;
    var ids={}
    var obj=document.getElementsByName('checkAll');
    for (var i = 0; i < obj.length; i++) {
        if(obj[i].checked){
                ids[key]={
                    id:obj[i].value
                }
                key++;
        }
    };
    ids=JSON.stringify(ids);

    $.ajax({
        url:'__MODULE__/Device/ever_del',
        data:ids,
        type:'POST',
        dataType:'json',
        success:function(result){
            // alert(JSON.stringify(result));
            if(result.status==1){
                layer.alert(result.info,function(){self.location="__MODULE__/Device/Index";});
            }else if(result.status==0){
                //失败
                layer.alert(result.info);
            }

        }
    });
}

//当选中所有的时候，全选按钮会勾上
function setSelectAll()
{
var obj=document.getElementsByName("checkAll");
var count = obj.length;
var selectCount = 0;

for(var i = 0; i < count; i++)
{
if(obj[i].checked == true)
{
selectCount++;
}
}
if(count == selectCount)
{
document.all.selAll.checked = true;
}
else
{
document.all.selAll.checked = false;
}
}

//反选按钮
function inverse() {
var checkboxs=document.getElementsByName("checkAll");
for (var i=0;i<checkboxs.length;i++) {
  var e=checkboxs[i];
  e.checked=!e.checked;
  setSelectAll();
}
}
</script>
